package com.zy.baselib.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.TextView
import androidx.annotation.AttrRes
import com.zy.baselib.R

class XLoadingView(context: Context, attrs: AttributeSet?, @AttrRes defStyleAttr: Int) : FrameLayout(context, attrs, defStyleAttr) {

    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)

    constructor(context: Context) : this(context, null)

    init {
        LayoutInflater.from(context).inflate(R.layout.layout_loading, this, true)
        val ob = context.obtainStyledAttributes(attrs, R.styleable.XLoadingView)
        val loadingText = ob.getString(R.styleable.XLoadingView_x_mv_loading_text)
        findViewById<TextView>(R.id.text_loading).text = if(loadingText.isNullOrEmpty()) "加载中..." else loadingText
        ob.recycle()
    }
}